package com.service.quartz.service;

import com.service.quartz.model.TaskModel;
import com.tool.base.library.http.HttpModel;
import com.tool.base.library.http.HttpResponse;
import com.tool.base.library.http.HttpUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class HttpJobService {

    @Autowired
    HttpUtil httpUtil;

    public String notify(TaskModel taskModel) throws Exception {
        String url = taskModel.getNotifyUrl();
        HttpModel httpModel = new HttpModel();
        httpModel.setRequestBody(taskModel.getNotifyData());
        HttpResponse response = httpUtil.postJson(url, httpModel);
        String body = response.getBody();
        // 获取结果实体
        log.warn("{}", body);
        return body;
    }
}
